<?php
// +----------------------------------------------------------------------
// | 用户签到
// +----------------------------------------------------------------------
namespace app\common\model;
use think\Model;

class UserSignLog extends Model
{
	/**
    * 签到
    * @param type $ids
    * @param type $v
    * @return type
    */
	public function signIn($uid,$shopId)
    {
    	$res = self::where('uid',request() ->userId)->whereTime('add_time', 'today')->find();
    	if($res){
    		throw new \think\Exception("您今天已经签到！");
    	}
    	$integral = model("shop_param")->where('shop_id',$shopId)->value('integral_sign') ?: 0;
    	$res = model("user")->addIntegral($uid,$integral,'',2);
    	$res = $res && self::save(['uid'=>$uid]);
    	return $integral;
    }
}
